package com.usaas.search.controller.admin;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.usaas.common.core.controller.BaseController;
import com.usaas.common.core.domain.AjaxResult;
import com.usaas.common.enums.BusinessType;
import com.usaas.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.usaas.common.annotation.Log;
import com.usaas.search.dto.PlatMessageCategoryDto;
import com.usaas.search.service.IPlatMessageCategoryService;
/**
 * 平台推广信息—游戏分类Controller
 *
 * @author Helios
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/admin/search/platMessageCategory")
public class AdminPlatMessageCategoryController extends BaseController {

    @Autowired
    private IPlatMessageCategoryService platMessageCategoryService;

    /**
     * 查询平台推广信息—游戏分类列表
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageCategory:list')")
    @Log(title = "管理端平台推广信息—游戏分类list查询", businessType = BusinessType.OTHER)
    @PostMapping("/list")
    public AjaxResult list(@RequestBody PlatMessageCategoryDto platMessageCategoryDto) {
        List<PlatMessageCategoryDto> list = platMessageCategoryService.queryList(platMessageCategoryDto);
        return AjaxResult.success(list);
    }


    /**
     * 查询平台推广信息—游戏分类分页列表
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageCategory:list')")
    @Log(title = "管理端平台推广信息—游戏分类page查询", businessType = BusinessType.OTHER)
    @PostMapping("/page")
    public AjaxResult page(@RequestBody PlatMessageCategoryDto platMessageCategoryDto) {
        return platMessageCategoryService.queryPage(platMessageCategoryDto);
    }


    /**
     * 导出平台推广信息—游戏分类列表
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageCategory:export')")
    @Log(title = "管理端导出平台推广信息—游戏分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,PlatMessageCategoryDto platMessageCategoryDto) {
        List<PlatMessageCategoryDto> list = platMessageCategoryService.queryList(platMessageCategoryDto);
        ExcelUtil<PlatMessageCategoryDto> util = new ExcelUtil<>(PlatMessageCategoryDto.class);
        util.exportExcel(response, list, "平台推广信息—游戏分类数据");
    }

    /**
     * 获取平台推广信息—游戏分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageCategory:query')")
    @Log(title = "管理端获取平台推广信息—游戏分类详情查询", businessType = BusinessType.OTHER)
    @PostMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestBody PlatMessageCategoryDto platMessageCategoryDto) {
        return AjaxResult.success(platMessageCategoryService.queryById(platMessageCategoryDto.getId()));
    }

    /**
     * 新增平台推广信息—游戏分类
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageCategory:add')")
    @Log(title = "管理端新增平台推广信息—游戏分类", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody PlatMessageCategoryDto platMessageCategoryDto) {
        return toAjax(platMessageCategoryService.add(platMessageCategoryDto));
    }

    /**
     * 修改平台推广信息—游戏分类
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageCategory:edit')")
    @Log(title = "管理端修改平台推广信息—游戏分类", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/edit")
    public AjaxResult edit(@RequestBody PlatMessageCategoryDto platMessageCategoryDto) {
        return toAjax(platMessageCategoryService.update(platMessageCategoryDto));
    }

    /**
     * 删除平台推广信息—游戏分类
     */
    @PreAuthorize("@ss.hasPermi('search:platMessageCategory:remove')")
    @Log(title = "管理端删除平台推广信息—游戏分类", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public AjaxResult del(@RequestBody PlatMessageCategoryDto platMessageCategoryDto) {
        return toAjax(platMessageCategoryService.removeBatch(platMessageCategoryDto.getIds()));
    }

}
